#include <iostream>

#include "Timer.h"

Timer::Timer(int delay, int interval, void * arg)
{
    ACE_Time_Value t1(delay);
    ACE_Time_Value t2(interval);
    this->m_reactorId = ACE_Reactor::instance()->schedule_timer(this,arg,t1,t2);
}

Timer::~Timer()
{
    ACE_Reactor::instance()->cancel_timer(this->m_reactorId);
}

//callback function
int Timer::handle_timeout(const ACE_Time_Value &current_time, const void *act)
{
    char *p = (char*) act;
    std::cout << "time out:";
    if (p)
        std::cout << p;
    std::cout << std::endl;

	//Sleep(5000);
    return 0;
}